All Questions
Tagged with nested-loopsdictionary
117 questions
2votes
2answers
275views
Ansible: Creating report with dictionary key and sub-elements in list of dictionaries
I have a dictionary. Each element contains a list dictionaries. I would like to create a report containing the keys of the primary dictionary and the subelements of each of the subordinate ...
3votes
2answers
245views
efficient python function to get value of specific key in nested dict without an external lib and without knowing concret static path to key in dict
The following initial situation: I am looking for a custom function that will extract a corresponding value from a nested dict and return it without external libs and without kowning the whole static ...
1vote
1answer
37views
How to loop through the values of the dictionaries which are nested as values in a json file?
I'm trying to loop through the values of "Location" key in the dictionaries of the following json file and find the number of entries for a specific location. How could I do that? My loop ...
1vote
0answers
47views
Why is my python dictionary updating when it is not supposed to (conditions are not being met)?
I am trying to update a dictionary with data I am obtaining from sorting methods. I am obtaining the time it takes for a certain algorithm to finish, I am also counting how many swaps and how many ...
0votes
1answer
37views
Why is only half my data being passed into my dictionary?
When I run this script I can verify that it loops through all of the values, but not all of them get passed into my dictionary file = open('path', 'rb') readFile = PyPDF2.PdfFileReader(file) lineData ...
1vote
2answers
92views
Iterate a nested dictionary and filter specific fields
I have an example object which is mixed of lists and dicts: { "field_1" : "aaa", "field_2": [ { "name" : "bbb", ........
1vote
2answers
300views
How to iterate a mixed of nested list and dict and filter items
I have an example object which is mixed of lists and dicts: { "field_1" : "aaa", "field_2": [ { "field_3" : "bbb", .....
0votes
0answers
27views
Get a key's value if another key has a certain value
I'm trying to get data from an api that returns multiple items when called like the following [{"rate":2.5,"price":123,"userAsset":{"userId":123,"...
-3votes
1answer
46views
How can i get the answer like output? What will be the code
How can I get the answer like output? What will be the code. x={1:"datascience", 2:"Machine learning", 3:"Pythone"} Output: {1:{d:1,a:2....}, 2:{M:1,a:2,...},3:{P:1,y:1,....
1vote
0answers
103views
Is there a function to quickly perform a nested loop in python?
In my code I have a list1 of about length 12000 and a list2 of about length 2000, and I want to create data that is based on how data from both these interact and assign it to each value from list2 ...
0votes
1answer
67views
PYTHON : Nested loop from a dictionnary to dataframe
I Everyone, I have a dictionary with a list of Dataframe Name as Key and URL as Value : {'Season': '/api/DATA/SEASON', 'Division': '/api/DATA/DIVISION', 'Group': '/api/DATA/GROUP'} And Dataframe ...
0votes
1answer
71views
How do I add values in a list that is inside a dictionary?
I have a JSON file that called jdata_list, it looks like: jdata_list = [{'API': 'AdoptAPet', 'Description': 'Resource to help get pets adopted', 'Auth': 'apiKey', 'HTTPS': True, 'Cors': 'yes', 'Link': ...
3votes
2answers
739views
Update Nested Dictionary value using Recursion
I want to update Dict dictionary's value by inp dictionary's values using recursion or loop. also the format should not change mean use recursion or loop on same format please suggest a solution that ...
0votes
5answers
56views
How can I use nested loop to create the dictionary I want?
I want to create a dictionary like : {0: {0: 1, 1: 2, 2: 3, 3: 4, 4: 5}, 1: {0: 6, 1: 7, 2: 8, 3: 9, 4: 10}, 2: {0: 11, 1: 12, 2: 13, 3: 14, 4: 15}, 3: {0: 16, 1: 17, 2: 18, 3: 19, 4: 20}} And ...
0votes
1answer
40views
Generate new keys on descending order of values in nested dictionary
Input dictionary is dict1={'AB':{'QB':0.11,'CD':0.10,'DE':0.4},'CD':{'FE':0.33,'TEW':0.22,'FEW':0.99,'FEQ':0.45}} Output dictionary is output={'AB':{2:{'QB':0.11},3:{'CD':0.10},1:{'DE':0.4}}, 'CD'...